/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Chung
 */
@Entity
@Table(name = "Employee")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"),
    @NamedQuery(name = "Employee.findByUsername", query = "SELECT e FROM Employee e WHERE e.username = :username"),
    @NamedQuery(name = "Employee.findByPassword", query = "SELECT e FROM Employee e WHERE e.password = :password"),
    @NamedQuery(name = "Employee.findByEmail", query = "SELECT e FROM Employee e WHERE e.email = :email"),
    @NamedQuery(name = "Employee.findByFullname", query = "SELECT e FROM Employee e WHERE e.fullname = :fullname"),
    @NamedQuery(name = "Employee.findByGender", query = "SELECT e FROM Employee e WHERE e.gender = :gender"),
    @NamedQuery(name = "Employee.findByBirthdate", query = "SELECT e FROM Employee e WHERE e.birthdate = :birthdate"),
    @NamedQuery(name = "Employee.findByPhone", query = "SELECT e FROM Employee e WHERE e.phone = :phone"),
    @NamedQuery(name = "Employee.findByMobilephone", query = "SELECT e FROM Employee e WHERE e.mobilephone = :mobilephone"),
    @NamedQuery(name = "Employee.findByAddress", query = "SELECT e FROM Employee e WHERE e.address = :address"),
    @NamedQuery(name = "Employee.findByIdentityCard", query = "SELECT e FROM Employee e WHERE e.identityCard = :identityCard"),
    @NamedQuery(name = "Employee.findByJoinInDate", query = "SELECT e FROM Employee e WHERE e.joinInDate = :joinInDate"),
    @NamedQuery(name = "Employee.findByPosition", query = "SELECT e FROM Employee e WHERE e.position = :position"),
    @NamedQuery(name = "Employee.findByDepartments", query = "SELECT e FROM Employee e WHERE e.departments = :departments"),
    @NamedQuery(name = "Employee.findByGroup", query = "SELECT e FROM Employee e WHERE e.group = :group"),
    @NamedQuery(name = "Employee.findByStatus", query = "SELECT e FROM Employee e WHERE e.status = :status"),
    @NamedQuery(name = "Employee.findByOnline", query = "SELECT e FROM Employee e WHERE e.online = :online"),
    @NamedQuery(name = "Employee.findByLogged", query = "SELECT e FROM Employee e WHERE e.logged = :logged"),
    @NamedQuery(name = "Employee.findByAvatar", query = "SELECT e FROM Employee e WHERE e.avatar = :avatar")})
public class Employee implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "username")
    private Collection<ContactMessage> contactMessageCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "username")
    private Collection<EventRegistration> eventRegistrationCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "username")
    private Collection<PictureLibrary> pictureLibraryCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "username")
    private Collection<EventComment> eventCommentCollection;
    @OneToMany(mappedBy = "username")
    private Collection<EventGift> eventGiftCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Username")
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Password")
    private String password;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Fullname")
    private String fullname;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Gender")
    private String gender;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Birthdate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date birthdate;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Phone")
    private String phone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Mobilephone")
    private String mobilephone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "Address")
    private String address;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "IdentityCard")
    private String identityCard;
    @Column(name = "JoinInDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date joinInDate;
    @Size(max = 100)
    @Column(name = "Position")
    private String position;
    @Size(max = 100)
    @Column(name = "Departments")
    private String departments;
    @Size(max = 200)
    @Column(name = "[Group]")
    private String group;
    @Size(max = 20)
    @Column(name = "Status")
    private String status;
    @Column(name = "Online")
    private Boolean online;
    @Column(name = "Logged")
    @Temporal(TemporalType.TIMESTAMP)
    private Date logged;
    @Size(max = 200)
    @Column(name = "Avatar")
    private String avatar;

    public Employee() {
    }

    public Employee(String username) {
        this.username = username;
    }

    public Employee(String username, String password, String email, String fullname, String gender, Date birthdate, String phone, String mobilephone, String address, String identityCard) {
        this.username = username;
        this.password = password;
        this.email = email;
        this.fullname = fullname;
        this.gender = gender;
        this.birthdate = birthdate;
        this.phone = phone;
        this.mobilephone = mobilephone;
        this.address = address;
        this.identityCard = identityCard;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFullname() {
        return fullname;
    }

    public void setFullname(String fullname) {
        this.fullname = fullname;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Date getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(Date birthdate) {
        this.birthdate = birthdate;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getMobilephone() {
        return mobilephone;
    }

    public void setMobilephone(String mobilephone) {
        this.mobilephone = mobilephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getIdentityCard() {
        return identityCard;
    }

    public void setIdentityCard(String identityCard) {
        this.identityCard = identityCard;
    }

    public Date getJoinInDate() {
        return joinInDate;
    }

    public void setJoinInDate(Date joinInDate) {
        this.joinInDate = joinInDate;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getDepartments() {
        return departments;
    }

    public void setDepartments(String departments) {
        this.departments = departments;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Boolean getOnline() {
        return online;
    }

    public void setOnline(Boolean online) {
        this.online = online;
    }

    public Date getLogged() {
        return logged;
    }

    public void setLogged(Date logged) {
        this.logged = logged;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employee)) {
            return false;
        }
        Employee other = (Employee) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.Employee[ username=" + username + " ]";
    }

    @XmlTransient
    public Collection<ContactMessage> getContactMessageCollection() {
        return contactMessageCollection;
    }

    public void setContactMessageCollection(Collection<ContactMessage> contactMessageCollection) {
        this.contactMessageCollection = contactMessageCollection;
    }

    @XmlTransient
    public Collection<EventRegistration> getEventRegistrationCollection() {
        return eventRegistrationCollection;
    }

    public void setEventRegistrationCollection(Collection<EventRegistration> eventRegistrationCollection) {
        this.eventRegistrationCollection = eventRegistrationCollection;
    }

    @XmlTransient
    public Collection<PictureLibrary> getPictureLibraryCollection() {
        return pictureLibraryCollection;
    }

    public void setPictureLibraryCollection(Collection<PictureLibrary> pictureLibraryCollection) {
        this.pictureLibraryCollection = pictureLibraryCollection;
    }

    @XmlTransient
    public Collection<EventComment> getEventCommentCollection() {
        return eventCommentCollection;
    }

    public void setEventCommentCollection(Collection<EventComment> eventCommentCollection) {
        this.eventCommentCollection = eventCommentCollection;
    }

    @XmlTransient
    public Collection<EventGift> getEventGiftCollection() {
        return eventGiftCollection;
    }

    public void setEventGiftCollection(Collection<EventGift> eventGiftCollection) {
        this.eventGiftCollection = eventGiftCollection;
    }
    
}
